const TokenExpirekey = 'user_expire';
const TokenKey = 'user_token';

//获取token
export function getToken() {
  let token = localStorage.getItem(TokenKey);
  let expireTime = localStorage.getItem(TokenKey);
  let dateNow = new Date().getTime();
  if(token && expireTime < dateNow) {
    removeToken();
    token = null;
  }
  return token;
}
//设置token
export function setToken(value) {
  localStorage.setItem(TokenKey,value);
  localStorage.setItem(TokenExpirekey,new Date().getTime()+60*60*1000);
}
//删除token
export function removeToken() {
  localStorage.removeItem(TokenKey);
  localStorage.removeItem(TokenExpirekey);
}

